<script setup name="Index">
import SearchForm from '@/components/SearchForm/SearchForm.vue'
import { tableOptions } from '@/plugins/vxetable.js'
import modal from "@/plugins/modal.js";

const table = reactive({
  ...tableOptions(),
  columns: [
    {
      field: 'id',
      title: 'ID',
      width: 80,
      visible: false,
    },
    {
      field: 'name',
      title: 'Name',
      width: 200,
      editRender: {
        type: 'input',
        attrs: {
          placeholder: 'Please input name',
        },
      },
    },
    {
      field: 'age',
      title: 'Age',
      width: 100,
      editRender: {
        type: 'input',
        attrs: {
          type: 'number',
          placeholder: 'Please input age',
        },
      },
    },
    {
      field: 'address',
      title: 'Address',
      width: 300,
      editRender: {
        type: 'textarea',
        attrs: {
          placeholder: 'Please input address',
        },
      },
    },
  ],
  data: [
    { id: 1, name: 'John', age: 20, address: 'New York' },
    { id: 2, name: 'Smith', age: 25, address: 'London' },
    { id: 3, name: 'Lee', age: 30, address: 'Paris' },
  ],
  pagerConfig: {
    pageSize: 10,
    pageSizes: [10, 20, 30, 40, 50],
  },
})
const initData = ref({
  keyword: '',
  status: '',
})

const searchColumns = [
  {
    type: 'input',
    label: '关键词',
    field: 'keyword',
    placeholder: '请输入关键词',
  },
  {
    type: 'select',
    label: '状态',
    field: 'status',
    options: {
      data: [
        { label: '启用', value: 'enabled' },
        { label: '禁用', value: 'disabled' },
      ],
    },
    placeholder: '请选择状态',
  },
  {
    type: 'date',
    label: '开始日期',
    field: 'startDate',
    dateType: 'date',
    placeholder: '选择开始日期',
  },
  {
    type: 'date',
    label: '结束日期',
    field: 'endDate',
    dateType: 'date',
    placeholder: '选择结束日期',
  },
]

function handleSearch(params) {
  console.log('搜索参数：', params)
}

function handleClick() {
  console.log('点击事件')
  modal.msgSuccess('1')
}
</script>

<template>
  <div class="app-container home">
    <SearchForm
      :columns="searchColumns"
      :init-data="initData"
      @search="handleSearch"
    />
    <vxe-grid
      v-bind="table"
    />
  </div>
  <el-card shadow="never" body-class="!p-0">
    <ResultPage
      type="fail"
      title="提交失败"
      description="请根据以下提示修改后重试"
      :error-list="['账户已被冻结', '权限不足']"
    />
  </el-card>
  <el-card>
    <el-button @click="handleClick">
      12
    </el-button>
  </el-card>
</template>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>
